package ext.wxcp;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import ext.wxcp.bean.WxCpAgent;
import ext.wxcp.bean.WxCpAgentGsonAdapter;
import ext.wxcp.bean.WxCpCorp;
import ext.wxcp.bean.WxCpCorpGsonAdapter;
import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.util.json.WxErrorAdapter;
import me.chanjar.weixin.cp.bean.WxCpDepart;
import me.chanjar.weixin.cp.bean.WxCpMessage;
import me.chanjar.weixin.cp.bean.WxCpTag;
import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.util.json.WxCpMessageGsonAdapter;
import me.chanjar.weixin.cp.util.json.WxCpTagGsonAdapter;
import me.chanjar.weixin.cp.util.json.WxCpUserGsonAdapter;

/**
 * Gson类型Builder.
 */
public class MyWxCpGsonBuilder {

    public static final GsonBuilder INSTANCE = new GsonBuilder();

    public MyWxCpGsonBuilder() {
    }

    public static Gson create() {
        return INSTANCE.create();
    }

    static {
        INSTANCE.disableHtmlEscaping();
        INSTANCE.registerTypeAdapter(WxCpMessage.class, new WxCpMessageGsonAdapter());
        INSTANCE.registerTypeAdapter(WxCpDepart.class, new ext.wxcp.bean.WxCpDeptartGsonAdapter ());
        INSTANCE.registerTypeAdapter(WxCpUser.class, new WxCpUserGsonAdapter());
        INSTANCE.registerTypeAdapter(WxCpAgent.class, new WxCpAgentGsonAdapter());
        INSTANCE.registerTypeAdapter(WxError.class, new WxErrorAdapter());
        INSTANCE.registerTypeAdapter(WxCpTag.class, new WxCpTagGsonAdapter());
        INSTANCE.registerTypeAdapter(WxCpCorp.class, new WxCpCorpGsonAdapter());
    }
}
